<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php 
require 'DataLoad.php';

$sql='select * from guild LIMIT 0,1';
$results= mysql_query($sql);

$rowfield=mysql_fetch_row($results);
$GuildName=$rowfield[1];
$GuildsName=$rowfield[2];
?>
<html>
<head>
<title><?php echo $GuildName;?> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<?php echo $StylePath;?>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<?php echo $StylePath;?>/styleplus.js"></script>
<style type="text/css" media="all">

</style>
<script type=text/javascript>
</script>

</head>

<body>
<div class="header">
</div>
<div class="main">
		<?php
@ $action=$_GET['Action'];
 if ($action=='Logout') {
 	unset($_SESSION['adminname']);
 	unset($_SESSION['level']);
 	session_destroy();
 	ReDirectUrl('default.php');
 	exit;
 }
		
		
	try {
		if (!isset($_POST['u_name']) || !isset($_POST['u_password']) || empty($_POST['u_name']) || empty($_POST['u_password'])) {
			throw new Exception('没有输入用户名或密码！');
		}
		$uname=checkstr($_POST['u_name']);
				$upass=sha1(checkstr($_POST['u_password']));
		$sqladmin="select * from admin where admin_name='".$uname."' and admin_password='".$upass."' LIMIT 0,1";
				$result=mysql_query($sqladmin);
		if (mysql_num_rows($result) >0) {
			$row = mysql_fetch_array($result);
			$_SESSION['adminname']=$row['admin_name'];
			$_SESSION['level']=$row['admin_level'];
			ReDirectUrl('default.php');
		}
		else{throw new Exception('用户名或者密码错误，请重新输入！');}
		
		}
	catch (Exception $e) {
		echo '<script language=javascript>alert("在登录时发生以下错误：'.$e->getMessage().'")</script>';
		ReDirectUrl('default.php');

	}
			
// [unsupported] session.timeout=999;
/*
if (SafeRequest(${"u_name"}) && ${"u_name"}!="" && ${"u_password"}!="") {

	$sql="select top 1 * from admin where admin_name='".${"u_name"}."'";
	$result = mysql_query($sql);
	if ($result->bof || $result->eof) {

showerror("找不到用户. <a href='.'>返回</a>");
	}
		else
	{

		if (${"u_password"}!=$result["admin_password"] && $md5[${"u_password"}]!=$result["admin_password"]) {

showerror("登录失败. <a href='.'>返回</a>");
		}
			else
		{

			session_register($USID);
$_SESSION[$USID]=${"U_name"};
			session_register($ULVL);
$_SESSION[$ULVL]=$result["admin_level"];
			header("Location: "."default.php");
		} 

	} 

	$result->close;
}
	else
{

	if (${"Action"}=="Logout") {

		session_register($USID);
$_SESSION[$USID]="";
		session_register($ULVL);
$_SESSION[$ULVL]="";
	} 

	ReDirectUrl('default.php');
} 
*/
?>
			</div>
<div id="footer"></div>
</body>
</html>
